<template>
    <div>
        <!-- 搜索框 -->
        <div class="search_all_intop" :style="search_intop" v-if="searchISshow"> </div>
        <div class="search_all" v-if="searchISshow">
            <span class="search_span clear">
                <i class="iconfont icon-sousuo"></i>
                <input type="text" v-model="search" placeholder="搜索">
                <i class="iconfont icon-guanbi" v-if="clearShow" @click="clearClick"></i>
            </span>
            <button class="search_cancel fr" @click="searchCancel">取消</button>
        </div>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                // searchISshow: false,   //关键字搜索框出现
                // search_intop: '',      //搜索框遮罩层
                search: ''
            }
        },
        watch: {
            search(value) {
              console.log('获取input值1231', value);
                // if(value != '') {
                //     this.clearShow = true;
                //     this.search_intop = 'background-color: transparent; z-index: 0;';
                // }else {
                //     this.clearShow = false;
                //     this.search_intop = 'background-color: rgba(0, 0, 0, 0.5);';
                // }
              this.$emit('spot', value);
            }
        },
        methods: {
            clearClick() {
                this.search = '';
                this.$emit('clearClick', this.search);
            },
            searchCancel() {
                this.search = '';
                this.$emit('searchCancel', this.search);
                console.log('清除了');
            },
        },
        props: ['search_intop', 'searchISshow', 'clearShow', 'spot']
    }
</script>

<style>
/* 关键字搜索 */
.search_all_intop {
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    position: absolute;
    top: 0;
    left: 0;
    z-index: 12;
}
.search_all {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 12;
    background-color: #e50838;
    width: 100%;
    height: 0.88rem;
    line-height: 0.88rem;
}
.search_all .search_span {
    position: relative;
    width: 100%;
    height: 0.88rem;
}
.search_all .search_span .icon-sousuo {
    font-size: 0.3rem !important;
    position: absolute;
    left: 0;
    top: 0;
    margin: 0.16rem 0.2rem 0 -0.6rem;
    box-sizing: border-box;
    height: 0.88rem;
    margin-bottom: -0.3rem;
}
.search_all .search_span input {
    display: inline-block;
    width: 6.5rem;
    margin: 0 auto;
    margin-left: -0.7rem;
    height: 0.54rem;
    line-height: 0.54rem;
    background-color: #fff;
    margin-top: -0.1rem;
    border-radius: 4px;
    padding-left: 0.5rem;
    font-size: 0.28rem;
}
.search_all .search_span .icon-guanbi {
    position: absolute;
    top: 0;
    right: 0;
    margin: 0.14rem 0.12rem 0 0.12rem;
}
.search_all .search_cancel {
    margin-top: -0.65rem;
    margin-right: 0.12rem;
    font-size: 0.28rem;
    color: #fff;
}

</style>